#ifndef MODELAUDIOFILES_H
#define MODELAUDIOFILES_H

#include <QAbstractTableModel>
#include <QHash>

#include "audiofile.h"

class ModelAudioFiles : public QAbstractTableModel
{
    Q_OBJECT
    Q_DISABLE_COPY(ModelAudioFiles)

public:
    enum ColumnIndex
    {
        Filename,
        NoOfPlaylistEntries,
        Tags,
        Cover,
        Lyrics,
        MaxColIdx,
    };

    explicit ModelAudioFiles(QObject *parent = 0);
    ~ModelAudioFiles();

    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation,
                                int role = Qt::DisplayRole) const;
    virtual Qt::ItemFlags flags(const QModelIndex& index) const;
    virtual QStringList mimeTypes() const;
    virtual QMimeData *mimeData(const QModelIndexList& indexes) const;

    int loadFiles(const QString& i_dir);

    inline const QList<AudioFile*>& files() const {return m_files;}
    inline const QHash<QString, AudioFile*>& filesHash() const {return m_hash;}

    static const QString MIME_TYPE;

private slots:
    void audioFileChanged();

private:
    QList<AudioFile*> m_files;
    QHash<QString, AudioFile*> m_hash;

    static const QBrush NOPLAYLIST_BRUSH;
    static const QBrush MOREPLAYLISTS_BRUSH;
};

#endif // MODELAUDIOFILES_H
